<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="__CSS__/pintuer.css?v={$src_version}">
<link rel="stylesheet" href="__CSS__/admin.css?v={$src_version}">
<link rel="stylesheet" href="__CSS__/responsive.css?v={$src_version}">
<script src="__JS__/jquery-3.2.1.min.js?v={$src_version}"></script>
<script src="__JS__/pintuer.js?v={$src_version}"></script>
<script src="__JS__/jquery.nicescroll.js"></script>
<script src="__PUBLIC__/layer.js?v={$src_version}"></script>
<script src="__JS__/ming.js?v={$src_version}"></script>
<script src="__JS__/ifram_scroll.js?v={$src_version}"></script>
<script src="__JS__/responsive.js?v={$src_version}"></script>   
<body>
<div class="panel admin-panel">
<div class="padding">   
  <form method="post" action="{:U('Manager/index')}?act=search" class="search-form" id="frm1">
      <ul class="search" >
       <li>
          <input type="text" value="{$con.keywords}" placeholder="请输入姓名或联系方式" name="keywords" class="input" style="width:250px; line-height:17px;display:inline-block"  />
         </li>
        <li>   
         <a href="javascript:void(0)" class="button border-main icon-search" id="dosearch" style="padding: 10px 15px;" > 搜索</a>
         
         </li>
      </ul>
    </form>  
		</div>
		<a type="button" class="button border-yellow" onclick="window.location.href='{:U('Manager/add')}'" style=" display:inline-block;padding:3px 5px; ">
			<span class="icon-plus-square-o"></span>添加部门主管
		</a> 
    <table class="table table-hover text-center">
      <tr>
        <th></th>
        <th style="text-align:left;">登录帐号(手机号)</th>
        <th>姓名</th>
        <th>部门名称</th>
        <th>操作</th>
      </tr>
      <volist name="manager" id="v">
        <tr>
          <td>
         <if condition="$v['is_admin'] neq '1'">  <input type="checkbox" name="id[]" value="{$v.aid}" /> </if>
        </td>
          <td style="text-align:left;">{$v.aname} <if condition="$v['is_admin'] eq '1'">[<i style="color:#006; font-style:normal;">超级管理员</i>]</if></td>
         <td>{$v.arealname}</td>
         <td>{$v.dname_name}</td>
      
          <td> 
          <div class="button-group"> 
           <a class="button border-main" href="{:U('Manager/add')}?id={$v.aid}"><span class="icon-edit"></span> 修改</a> 
             <if condition="$v['is_admin'] neq '1'">
              
              <a class="button border-red" href="javascript:void(0)" onclick="return del({$v.aid})"><span class="icon-trash-o"></span> 删除</a> 
              <else />
               
              <a  class="button border-main"  style="border:none; display:block; margin:0 auto; background:none;" href="javascript:void(0)">  </a>
            </if>  
          </div>
          </td>
        </tr>
        </volist>
  
 <?php if(intval(count($manager))>0){ ?>
 
         
   <tr  class="no-hover">
        <td style="text-align:left; padding:19px 0;padding-left:20px;">
        <input type="checkbox" id="checkall"/>
          全选 </td>
        <td colspan="80" style="text-align:left;"><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a> 
       
          </td>
      </tr>
      
       <tr  class="no-hover" style="border-bottom:none"> <td style="border-bottom:none" colspan="80"><div class="pagelist"><?php echo $page; ?></div></td></tr>  
          
      <?php }else{ ?>  
        
         <tr  class="no-hover"><td style="border-bottom:none" colspan="80"><div class="pagelist"><?php  echo '暂无记录'; ?></div></td></tr> 
                     
      <?php } ?>  
    </table>
  </div>

<script type="text/javascript">

$(function(){
	 //搜索
	$('#dosearch').click(function(){$('#frm1').submit();} );  
	
	 
});
 

//单个删除
function del(id){
	layer.confirm('您确定要删除吗?', {
        btn: ['确定','取消'] //按钮
     }, function(){
        
		//执行删除操作
		  $.ajax({
			type:'post',
			url:"{:U('Manager/del')}",
			data:{id:id},
			dataType:'json',
			success:function(res){
			  layer.msg(res.msg, {icon: res.code});
			  res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';
			}
		});
		
		 
		 
     });

}

//全选
$("#checkall").click(function(){ 

	if(this.checked)
	  {   
        	  $("input[name='id[]']").each(function(){
	              this.checked = true;
			  });
	   }
	   else
	   {   
			  $("input[name='id[]']").each(function(){
	              this.checked = false;
			  });
 
	  }   

 
});
//设置全选复选框
$("input[name='id[]']").click(function(){
	allchk();
});
function allchk(){
 
	var chknum= $("input[name='id[]']").length;//选项总个数
	var chk = 0;
	$("input[name='id[]']").each(function () {  
        if($(this).prop("checked")==true){
			chk++;
		}
    });
	if(chknum==chk){
		//全选
		$("#checkall").prop("checked",true);
	}else{
		//不全选
		$("#checkall").prop("checked",false);
	}
}

 

//批量删除
function DelSelect(){
	var Checkbox=false;
	var chk_id_arr=[];
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
		chk_id_arr.push($(this).val());
		
	  }
	});

	if (Checkbox){
  
	  layer.confirm('您确认要删除选中的记录吗?', {
        btn: ['确定','取消'] //按钮
     }, function(){
        
		//执行删除操作
	 $.ajax({
		 type:'post',
		 url:"{:U('Manager/del')}",
		 data:{id:chk_id_arr},	
		 dataType:'json',
		 success:function(res){
			 
			 layer.msg(res.msg, {icon: res.code});
		
			 res.code=='1'?setTimeout("goURL('"+res.url+"')",500):'';
		   }
			
		});
  
     });
 	 
	}
	else{
	 
	  layer.alert('请选择您要删除的记录!', {
	  skin: 'layui-layer-molv', //样式类名
	  closeBtn: 0});
	   return false;
	}
}
 
 
</script>

 

</body>
</html>